/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.purpose.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.koron.purpose.domain.PurposeObject;

public interface PurposeObjectMapper {
	
	@Insert("<script>"
			+ "insert into purpose_object(id,add_user,add_user_name,add_time,update_user,update_user_name,"
			+ "update_time,staff_code,area_code,corp_code,dept_code,staff_name,area_name,corp_name,dept_name,"
			+ "contract_name,contract_path,original_path,contract_pdf_path,note,purpose_contract_id) values"
			+ "<foreach collection ='beanList' item='item' index='index' separator =','>"
			+ "(#{item.id},#{item.addUser},#{item.addUserName},#{item.addTime},#{item.updateUser},#{item.updateUserName},#{item.updateTime},"
			+ "#{item.staffCode},#{item.areaCode},#{item.corpCode},#{item.deptCode},#{item.staffName},#{item.areaName},#{item.corpName},#{item.deptName},"
			+ "#{item.contractName},#{item.contractPath},#{item.originalPath},#{item.contractPdfPath},#{item.note},#{item.purposeContractId})"
			+ "</foreach>"
			+ "</script>")
	Integer batchInsert(@Param("beanList") List<PurposeObject> list);
	
	@Delete("delete from purpose_object where purpose_contract_id=#{id}")
	Integer deleteByContractId(@Param("id") String id);
	
	@Select("select * from purpose_object where purpose_contract_id=#{id}")
	List<PurposeObject> queryByContractId(@Param("id") String id);
	
	@Select("select * from purpose_object")
	List<PurposeObject> queryAll();
	
	@Select("select * from purpose_object where add_user=#{code}")
	List<PurposeObject> queryByCreater(@Param("code") String code);
	
	@Select("select * from purpose_object where staff_code=#{code}")
	List<PurposeObject> queryByStaffCode(@Param("code") String code);
	
	@Select("select * from purpose_object where area_code=#{code}")
	PurposeObject queryByAreaCode(@Param("code") String code);
	
	@Select("select * from purpose_object where corp_code=#{code}")
	PurposeObject queryByCorpCode(@Param("code") String code);
	
	@Select("select * from purpose_object where dept_code=#{code}")
	PurposeObject queryByDeptCode(@Param("code") String code);
}
